package com.ruoyi.system.api;

import com.ruoyi.system.api.model.WarmFlowInteractiveTypeVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import com.ruoyi.system.api.model.LoginUser;

import java.util.List;

/**
 * 用户服务
 *
 * @author RuoYi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 记录用户登录IP地址和登录时间
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PutMapping("/user/recordLogin")
    public R<Boolean> recordUserLogin(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户ID映射用户名称
     *
     * @param userId 用户ID
     * @param source 调用源
     * @return {@link R< String>}
     * @author liangli
     * @date 2024/12/14 10:05
     **/
    @GetMapping("/user/idMappingUserName/{userId}")
    R<String> idMappingUserName(@PathVariable("userId") String userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户ID映射用户名称
     *
     * @param deptId 部门ID
     * @param source 调用源
     * @return {@link R<String>}
     * @author liangli
     * @date 2024/12/14 10:05
     **/
    @GetMapping("/dept/idMappingDeptName/{deptId}")
    R<String> idMappingDeptName(@PathVariable("deptId") String deptId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户ID映射用户名称
     *
     * @param roleId 角色ID
     * @param source 调用源
     * @return {@link R<String>}
     * @author liangli
     * @date 2024/12/14 10:05
     **/
    @GetMapping("/role/idMappingRoleName/{roleId}")
    R<String> idMappingRoleName(@PathVariable("roleId") String roleId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户ID映射用户名称
     *
     * @param warmFlowInteractiveTypeVo 工作流交互类
     * @param source                    调用源
     * @return {@link R<List<SysUser>>}
     * @author liangli
     * @date 2024/12/14 10:05
     **/
    @GetMapping("/user/findUserIdList")
    R<List<SysUser>> findUserIdList(WarmFlowInteractiveTypeVo warmFlowInteractiveTypeVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
